<template>
    <div class="pageContainer">
        <div class="searchWarp">
            <el-form inline>
                <template v-for="condition in listCondition">
                    <CText :title="condition.name" v-model="condition.value"></CText>
                </template>
            </el-form>
            <div class="schLine">
                <CBtn @click="search(1)">查询</CBtn>
            </div>
        </div>
        <div class="treeTable">
            <div style="flex:1;">
                <div class="btnWarp">
                    <CBtn @click="showEdit">新增</CBtn>
                    <CBtn @click="doBatchDel()">批量删除</CBtn>
                </div>
                <CPageTable :data="tableData" :curPage="paging.curPage" :total="paging.total" 
                    @changeSelect="changeSelect"
                    @changeSize="changeSize" @changePage="search">
                    <template slot-scope="scope">
                        <CBtn type="text" @click="showEdit(scope.row)">修改</CBtn>
                        <CBtn type="text" @click="doDel(scope.row)">删除</CBtn>
                    </template>

                </CPageTable>
            </div>
        </div>

        <CDailog title="新增/编辑" :isShow="isShowEdit" @close="isShowEdit = false" @enter="doSave">
            <el-form :inline="true">
                <CText form v-model="mm.code" title="编码" field="code"></CText>
                <CText form v-model="mm.name" title="名称" field="name"></CText>
                <CText form v-model="mm.fkDefTypeId" title="分类" field="fkDefTypeId"></CText>
                <CText form v-model="mm.fkVersionId" title="版本" field="fkVersionId"></CText>
                <CText form v-model="mm.val" title="值" field="val"></CText>
            </el-form>
        </CDailog>
    </div>
</template>

<script>
import pagingMixin from '@/mixin/pagingMixin'
export default {
    mixins: [pagingMixin],
    data() {
        return {
            treeData: [],
            inForm: {
                name: ""
            },
            model: "sys",
            table: "SysDef"
            
        }
    },
    created() {
        this.templateId = "392c79f2-88be-4c80-a5cb-274a58321b6e";
        
        //取得查询条件
        this.$sys.getPageConditions({id: this.templateId}).then(res => {
            this.listCondition = res.data;
        })
        //查询表格数据
        this.search(1);
    },
    methods: {
        searchTree() {
            this.$sys.getTreeByCode({code: "tree_def_type"}).then(res => {
                this.treeData = res.data;
            })
        },
        nodeClick(node) {
            let conditions = [...this.listCondition];
            this.$u.addWhere(conditions, "fk_def_type_id", node.id);
            this.search(1, conditions);
        },
        
    }
}
</script>

<style lang="scss" scoped></style>